#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <cstdio>

using std::cout;
using std::endl;

void Count(int count)
{
    while (count)
    {
        printf("count : %2d\r", count);
        fflush(stdout);
        --count;
        sleep(1);
    }
    cout << endl;
}
void handler(int signo)
{
    cout << "try a signo : " << signo << endl;
    Count(20);
}
int main()
{
    struct sigaction act, oact;
    act.sa_handler = handler;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,3);//将3号信号添加到act.sa_mask就完成屏蔽3号信号了
    sigaction(SIGINT, &act, &oact);

    while (1)
    {
        sleep(1);
    }

    return 0;
}